<template>
  <div class="MyBox">
    <div class="width">
      <br />
      <div class="user-card">
        <div class="bg"></div>
        <div class="user-info">
          <div>
            <div class="avatar">
              <img :src="userinfo.avatar" alt="" />
            </div>
          </div>
          <div class="info">
            <div class="name">
              <span>{{ userinfo.nickname }}</span>
              <div class="vip">
                <img :src="userinfo.vip_icon" alt="" />
                <div class="vip-txt">
                  {{ userinfo.vip_name }}
                </div>
              </div>
            </div>
            <div class="num">
              <div class="num-txt">ID: {{ userinfo.spread_uid }}</div>
              <div class="icon">
                <img src="http://47.93.101.203/static/images/edit.png" alt="" />
              </div>
            </div>
          </div>
        </div>
        <div class="num-wrapper">
          <div class="num-item">
            <div class="num">
              <span>{{ userinfo.now_money }}</span>
            </div>
            <div class="text">余额</div>
          </div>
          <div class="num-item">
            <div class="num">
              <span>{{ userinfo.integral }}</span>
            </div>
            <div class="text">积分</div>
          </div>
          <div class="num-item">
            <div class="num">
              <span>{{ userinfo.couponCount }}</span>
            </div>
            <div class="text">优惠卷</div>
          </div>
        </div>
        <div class="sign">签到</div>
      </div>
    </div>
    <div class="main">
      <ul>
        <li v-for="(v, i) in getMyMains" :key="i">
          <div class="left" @click="site(v)">
            {{ v.name }}
          </div>
          <div class="right">
            <van-icon name="arrow" />
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { getMy, getMyMain } from "@/api/request";
export default {
  data() {
    return {
      userinfo: [],
      getMyMains: [],
    };
  },
  methods: {
    site(val) {
      if (val.name == "地址信息") {
        this.$router.push("/site");
      } else {
        console.log(2);
      }
    },
  },
  created() {
    // 获取头部数据
    getMy().then((res) => {
      this.userinfo = res.data.data;
    });
    // 获取尾部数据
    getMyMain().then((res) => {
      this.getMyMains = res.data.data.routine_my_menus;
    });
  },
};
</script>

<style lang="less" scoped>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
.width {
  background: white;
}
.MyBox {
  width: 100%;
  height: 100%;
}
.sign {
  z-index: 200;
  position: absolute;
  right: -7px;
  top: 53px;

  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  width: 79px;
  height: 39px;

  background: linear-gradient(90deg, #ffe157, #eec10f);
  border-radius: 19px 2px 2px 19px;
  color: #282828;
  font-size: 18px;
  font-weight: 700;
}
.num-wrapper {
  z-index: 30;
  position: relative;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  margin-top: 23px;
  color: #fff;
  .num-item {
    width: 33.33%;
    text-align: center;
    .num {
      font-size: 20px;
      font-weight: 700;
    }
    .txt {
      margin-top: 5px;
      font-size: 17px;
      color: hsla(0, 0%, 100%, 0.6);
    }
  }
}
.user-card {
  position: relative;
  width: 96%;
  height: 170px;
  margin: 0 auto;
  padding: 17px 14px;
  // margin-top: 3%;
  background: linear-gradient(90deg, #f62c2c, #f96e29);
  box-shadow: 0 5px 10px 0 rgb(255 2 0 / 20%);
  border-radius: 12px;
  .bg {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-image: url(http://47.93.101.203/static/img/user_bg.11ed795e.png);
    background-size: 100% 100%;
  }
  .user-info {
    z-index: 20;
    position: relative;
    display: flex;
    .avatar {
      width: 60px;
      height: 60px;
      border-radius: 50%;
      img {
        width: 100%;
        height: 100%;
        border-radius: 50%;
      }
    }

    .info {
      -webkit-box-flex: 1;
      -webkit-flex: 1;
      flex: 1;
      display: flex;
      -webkit-box-orient: vertical;
      -webkit-box-direction: normal;
      -webkit-flex-direction: column;
      flex-direction: column;
      -webkit-box-pack: justify;
      -webkit-justify-content: space-between;
      justify-content: space-between;
      margin-left: 10px;
      padding: 7px 0;
      .name {
        display: flex;
        -webkit-box-align: center;
        -webkit-align-items: center;
        align-items: center;
        color: #fff;
        font-size: 15px;
        .vip {
          display: flex;
          -webkit-box-align: center;
          align-items: center;
          height: 18px;
          padding: 0 10px;
          background: rgba(0, 0, 0, 0.2);
          border-radius: 18px;
          font-size: 10px;
          margin-left: 6px;
          img {
            width: 13px;
            height: 13px;
          }
        }
      }
      .num {
        display: flex;
        -webkit-box-align: center;
        -webkit-align-items: center;
        align-items: center;
        font-size: 13px;
        color: hsla(0, 0%, 100%, 0.6);

        img {
          width: 11px;
          height: 11px;
          margin-left: 10px;
        }
      }
    }
  }
}
.main {
  width: 100%;
  margin-top: 20%;
  ul {
    background: white;
    li {
      width: 96%;
      margin-left: 2%;
      list-style: none;
      height: 40px;
      line-height: 40px;
      background: white;
      border-bottom: 1px solid #ccc;
      display: flex;
      .left {
        flex: 1;
      }
    }
  }
}
</style>